package com.scpii.api.common.auth.client;

import java.util.Collection;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

public class ClientAuthenticationToken extends
		AbstractAuthenticationToken {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private final Object principal;

	private Object credentials;

	private String deviceId;

	public ClientAuthenticationToken(
			Collection<? extends GrantedAuthority> authorities,
			Object principal, Object credentials) {
		super(authorities);
		this.principal = principal;
		this.credentials = credentials;
		setAuthenticated(true);
	}

	public ClientAuthenticationToken(
			Collection<? extends GrantedAuthority> authorities,
			Object principal, Object credentials, String deviceId) {
		super(authorities);
		this.principal = principal;
		this.credentials = credentials;
		this.deviceId = deviceId;
		setAuthenticated(true);
	}

	public ClientAuthenticationToken(Object principal,
			Object credentials, String deviceId) {
		super(null);
		this.principal = principal;
		this.credentials = credentials;
		this.deviceId = deviceId;
		setAuthenticated(false);
	}

	public ClientAuthenticationToken(Object principal,
			Object credentials,
			Collection<? extends GrantedAuthority> authorities) {
		super(authorities);
		this.principal = principal;
		this.credentials = credentials;
		super.setAuthenticated(true);
	}

	@Override
	public Object getCredentials() {
		return credentials;
	}

	@Override
	public Object getPrincipal() {
		return principal;
	}

	public void setCredentials(Object credentials) {
		this.credentials = credentials;
	}

	public String getDeviceId() {
		return deviceId;
	}

	public void setDeviceId(String deviceId) {
		this.deviceId = deviceId;
	}

}
